function cleanReplaceInviteHead(){
	$("#replaceInviteHeadId").val("");
	$("#replaceInviteHead").val("");
}
function cleanSupplier(){
	$("#replaceSupplierId").val("");
	$("#replaceSupplierNo").val("");
	$("#replaceSupplierName").val("");
	$("#replaceBrandId").empty();
	$("#replaceBrandId1").empty();
	$("#replaceBrandId2").empty();
	$("#replaceBrandId3").empty();
	$("#replaceBrandId").append("<option value=''> -----请选择-----</option>");
	$("#replaceBrandId1").append("<option value=''> -----请选择-----</option>");
	$("#replaceBrandId2").append("<option value=''> -----请选择-----</option>");
	$("#replaceBrandId3").append("<option value=''> -----请选择-----</option>");
}

$(document).ready(function() {
	var contextPath = Com_Parameter.ContextPath;
	if(replaceSupplierNo_edit !=""){
		$.get(contextPath+"/biz/contract/commonContract/"+replaceSupplierNo_edit+"/getBrandInfo",function(data){
			  var brandObj = eval('(' + data + ')');
			if(replaceBrand_edit !=""){
				$("#replaceBrandId").empty();
				 $("#replaceBrandId1").empty();
				   $("#replaceBrandId2").empty();
				   $("#replaceBrandId3").empty();
				  for(var i = 0;i<brandObj.length;i++){
					   var brand = brandObj[i];
					   $("#replaceBrandId").append("<option value='"+brand.id+"'>"+brand.name+"</option>");
					   $("#replaceBrandId1").append("<option value='"+brand.id+"'>"+brand.name+"</option>");
					   $("#replaceBrandId2").append("<option value='"+brand.id+"'>"+brand.name+"</option>");
					   $("#replaceBrandId3").append("<option value='"+brand.id+"'>"+brand.name+"</option>");
				  }
				  
				  $("#replaceBrandId").children("option").each(function(){
					  if($(this).text() ==replaceBrand_edit){
						  $(this).attr("selected",true);
					  }
				  });
				  $("#replaceBrandId1").children("option").each(function(){
					  if($(this).text() ==replaceBrand1_edit){
						  $(this).attr("selected",true);
					  }
				  });
				  $("#replaceBrandId2").children("option").each(function(){
					  if($(this).text() ==replaceBrand2_edit){
						  $(this).attr("selected",true);
					  }
				  });
				  $("#replaceBrandId3").children("option").each(function(){
					  if($(this).text() ==replaceBrand2_edit){
						  $(this).attr("selected",true);
					  }
				  });
			}
		});
	}
	

			  
			 //选择供应商 
		   $("#replaceSupplierButton").click(function(){
			   $("#supplierModal").load(contextPath+'/biz/brand/supplier/suppInfoPage?pageSize=10',function(){  
				    $("#supplierModal").modal("show");  
				}); 
		   });
		   
		   //根据选择的供应商带出品牌信息
		   $("#replaceBrandId").focus(function(){
			   var supplierNo = $("#replaceSupplierNo").val();
			   $.get(contextPath+"/biz/contract/commonContract/"+supplierNo+"/getBrandInfo",function(data){
				   var brandObj = eval('(' + data + ')');
				   $("#replaceBrandId").empty();
				   $("#replaceBrandId1").empty();
				   $("#replaceBrandId2").empty();
				   $("#replaceBrandId3").empty();
				   for(var i = 0;i<brandObj.length;i++){
					   var brand = brandObj[i];
					   $("#replaceBrandId").append("<option value='"+brand.id+"'>"+brand.name+"</option>");
					   $("#replaceBrandId1").append("<option value='"+brand.id+"'>"+brand.name+"</option>");
					   $("#replaceBrandId2").append("<option value='"+brand.id+"'>"+brand.name+"</option>");
					   $("#replaceBrandId3").append("<option value='"+brand.id+"'>"+brand.name+"</option>");
				   }
			   });
		   });
		   //选择品牌的时候给品牌名称设值
		   $("#replaceBrandId").change(function(){
			   var cname ;
			   var brandId;
			   $("#replaceBrandId").children("option").each(function(){
					if($(this).attr("selected") == "selected"){
						cname = $(this).text();
						brandId = $(this).val();
					}	
				});
			   $("#replaceBrand").val(cname);
			   $.get(contextPath+"/biz/intent/intAssterminate/getBrandInfo",function(data){
					   var brandObj = eval('(' + data + ')');
					   $("#brandSummary").text(brandObj.brandSummary);
			   });
		   });
		   
		   //选择品牌的时候给品牌名称设值
		   $("#replaceBrandId").change(function(){
			   var cname ;
			   var brandId;
			   $("#replaceBrandId").children("option").each(function(){
					if($(this).attr("selected") == "selected"){
						cname = $(this).text();
						brandId = $(this).val();
					}	
				});
			   $("#replaceBrand").val(cname);
			   $.get(contextPath+"/biz/intent/intAssterminate/getBrandInfo",function(data){
					   var brandObj = eval('(' + data + ')');
					   $("#brandSummary").text(brandObj.brandSummary);
			   });
		   });
		   
		   
		   //选择品牌的时候给品牌名称设值
		   $("#replaceBrandId1").change(function(){
			   var cname ;
			   var brandId;
			   $("#replaceBrandId1").children("option").each(function(){
					if($(this).attr("selected") == "selected"){
						cname = $(this).text();
						brandId = $(this).val();
					}	
				});
			   $("#replaceBrand1").val(cname);
		   });
		   
		   //选择品牌的时候给品牌名称设值
		   $("#replaceBrandId2").change(function(){
			   var cname ;
			   var brandId;
			   $("#replaceBrandId2").children("option").each(function(){
					if($(this).attr("selected") == "selected"){
						cname = $(this).text();
						brandId = $(this).val();
					}	
				});
			   $("#replaceBrand2").val(cname);
			
		   });
		   
		   //选择品牌的时候给品牌名称设值
		   $("#replaceBrandId3").change(function(){
			   var cname ;
			   var brandId;
			   $("#replaceBrandId3").children("option").each(function(){
					if($(this).attr("selected") == "selected"){
						cname = $(this).text();
						brandId = $(this).val();
					}	
				});
			   $("#replaceBrand3").val(cname);
			
		   });
		   //弹出选择合同信息列表
		   $("#add").click(function(){
			   var intentType = $("#intentType").val();
				$("#myModal").load(contextPath+'/biz/intent/'+intentType+'/getModuleContractList?pageSize=10&navId='+navId,function(){ 
				    $("#myModal").modal("show");
				}); 
			}); 
		   //保存撤柜意向
			$("#saveAssterminate").click(function (){
				$("#intAssterminateForm").submit();
			});
			//判断是否走逃场流程
			$("#submit_wokFlow").click(function(){
				var isTakeFlight = $("#isTakeFlight").attr("value");
				if(isTakeFlight =="1"){
					top.$.jBox.confirm('您选择的是逃场，确认要走逃场流程吗？','系统提示',function(v,h,f){
						if(v =="ok"){
							Oosp_Loading('正在提交，请稍等...');
							var path = $("#path").val();
							if($("#terminateDate").val() ==''||$("#terminateDate").val()==null){
								top.$.jBox.tip('预计撤柜日期  不能为空', 'warning');
								$("#terminateDate").focus();
								return;
							}
							$('#'+path+'Form').attr('action',contextPath+'/biz/intent/'+path+'/submit?navId='+navId);
							$("#"+path+"Form").submit();
						}
					});
					return;
				}else{
					Oosp_Loading('正在提交，请稍等...');
					var path = $("#path").val();
					if($("#terminateDate").val() ==''||$("#terminateDate").val()==null){
						top.$.jBox.tip('预计撤柜日期  不能为空', 'warning');
						return;
					}
					$('#'+path+'Form').attr('action',contextPath+'/biz/intent/'+path+'/submit?navId='+navId);
					$("#"+path+"Form").submit();
				}
			});
});


//*************************************************************************************************************************************		  
//选择合同信息
function btnOK_click(){
	var contextPath = Com_Parameter.ContextPath;
	var intentType = $("#intentType").val();
	$("#ok").attr("data-dismiss","modal");
	var ids = new Array(), i = 0;
	$('#modalTable').find("input[type='checkbox'][data-ckb-id]").each(function(){
		var $this = $(this);
		if($this.prop('checked')){
			ids.push($(this).attr("data-ckb-id"))  ;
		}
	});
	if(ids.length < 1){
		alert("请选择合同信息!");
		return;
	}
	if(ids.length > 1){
		alert("只能选择1条合同信息!");
		return;
	}
	var id = ids[0];
	$("#intentForm").attr('action',contextPath+'/biz/intent/'+intentType+'/'+id+'/'+navId+'/add');
	
	$("#intentForm").submit();
}


